from Mastergoal.Common.piece import PlayerPiece, BallPiece
from Mastergoal.Common.board import Board
from Mastergoal.Common.commonerror import BoardError
from Mastergoal.Common.team import Team
from Mastergoal.Common.square import Square
from Mastergoal.Common.state import State
from Mastergoal.Common.move import *
from Mastergoal.Rules.commonrules import CommonRules
from Mastergoal.Rules.level2rules import L2Rules
from Mastergoal.Rules.level3rules import L3Rules

if __name__ == '__main__': 
    ball = BallPiece(Square(7,5))
    team = Team(Team.DOWN)
    team2 = Team(Team.UP)
    
    board = Board(ball)
    board.add_team(team)
    board.add_team(team2)
   
    player = PlayerPiece(PlayerPiece.G, Square(7,4))
    player2 = PlayerPiece(PlayerPiece.G, Square(1,4))
    team.add_player(player)
    team2.add_player(player2)
    state = State(board, 1, team)
    
    move = PlayerMove(player, Square(1,0))
    
     
    ball_move = BallMove(ball, Square(10,6), player)
    
    #L2Rules.neutral_square_area(state, move, L2Rules)
    
    response = L3Rules.valid_ball_move(state, ball_move, L3Rules)
    print CommonRules.desc_rules[response[1]]



    #print board.special_square(player.orientation, player.square.col, player.square.row)

    #print L2Rules.neutral_square(state, move)
    
    #for k in board.get_keepers():
    #   print k
    
    #try:
    #    board.add_team(team)
    #except BoardError, e:
    #    print 'BoardException occurred, value: ', e.value